<?php
/**
 * Magento
 *
 * NOTICE OF LICENSE
 *
 * This source file is subject to the Academic Free License (AFL 3.0)
 * that is bundled with this package in the file LICENSE_AFL.txt.
 * It is also available through the world-wide-web at this URL:
 * http://opensource.org/licenses/afl-3.0.php
 * If you did not receive a copy of the license and are unable to
 * obtain it through the world-wide-web, please send an email
 * to license@magentocommerce.com so we can send you a copy immediately.
 *
 * DISCLAIMER
 *
 * Do not edit or add to this file if you wish to upgrade Magento to newer
 * versions in the future. If you wish to customize Magento for your
 * needs please refer to http://www.magentocommerce.com for more information.
 *
 * @copyright   Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com)
 * @license     http://opensource.org/licenses/afl-3.0.php  Academic Free License (AFL 3.0)
 */
/**
 * @var \Magento\Ui\FilterPool\View $this
 */
?>
<?php if (true): ?>
    <script data-mage-apply='{"Magento_Ui/js/listing/filter": ""}' type="application/json">
        <?php echo $this->getConfigurationBuilder()->toJson($this->getConfiguration()); ?>
    </script>
    <div data-bind="scope: '<?php echo $this->getParentName(); ?>:<?php echo $this->getName(); ?>'">
        <!-- ko template: 'ui/filter' --><!-- /ko -->
    </div>
<?php else: ?>
    <div class="filters" data-mage-apply='{"Magento_Ui/js/listing/filter": ""}'
         data-bind="scope: '<?php echo $this->getParentName(); ?>:<?php echo $this->getName(); ?>'">
        <button class="action filters-toggle" data-bind="click: toggle"><span
                data-bind-="text: $t('Filter')">Filter</span></button>
        <div class="form filters-form" data-bind-="visible: isVisible" data-part-="filter-form">
            <fieldset class="filters-fieldset fieldset">
                <legend class="legend filters-legend">
                    <span data-bind-="text: $t('Advanced filter')"></span>
                </legend>
                <br/>
                <?php foreach ($this->getFields() as $field): ?>
                    <?php echo $this->renderElement($field['filter_type'], $field); ?>
                <?php endforeach; ?>
            </fieldset>
            <div class="actions filters-actions">
                <button class="action primary action-apply" data-bind-="click: apply" type="button"><span
                        data-bind-="text: $t('Apply')"></span></button>
                <button class="action secondary action-reset" data-bind-="click: reset" type="button"><span
                        data-bind-="text: $t('Reset')"></span></button>
                <button class="action secondary action-close" data-bind-="click: close" type="button"><span
                        data-bind-="text: $t('Close')"></span></button>
            </div>
        </div>
        <div class="filters-current">
            <ul class="filters-items items">
                <?php foreach ($this->getActiveFilters() as $filter): ?>
                    <li class="filters-item item">
                        <?php echo $this->renderElement('filter', $filter); ?>
                    </li>
                <?php endforeach; ?>
            </ul>
            <button data-bind-="click: reset" class="action action-clear">
                <span data-bind-="text: $t('Clear all')"></span>
            </button>
        </div>
    </div>
<?php endif; ?>